package com.ruoyi.ufox.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ufox.mapper.BisDeviceMapper;
import com.ruoyi.ufox.domain.BisDevice;
import com.ruoyi.ufox.service.IBisDeviceService;

/**
 * 蔬菜机Service业务层处理
 * 
 * @author ufoxs
 * @date 2022-08-15
 */
@Service
public class BisDeviceServiceImpl implements IBisDeviceService 
{
    @Autowired
    private BisDeviceMapper bisDeviceMapper;

    /**
     * 查询蔬菜机
     * 
     * @param deviceId 蔬菜机主键
     * @return 蔬菜机
     */
    @Override
    public BisDevice selectBisDeviceByDeviceId(Long deviceId)
    {
        return bisDeviceMapper.selectBisDeviceByDeviceId(deviceId);
    }

    /**
     * 查询蔬菜机列表
     * 
     * @param bisDevice 蔬菜机
     * @return 蔬菜机
     */
    @Override
    public List<BisDevice> selectBisDeviceList(BisDevice bisDevice)
    {
        return bisDeviceMapper.selectBisDeviceList(bisDevice);
    }

    /**
     * 新增蔬菜机
     * 
     * @param bisDevice 蔬菜机
     * @return 结果
     */
    @Override
    public int insertBisDevice(BisDevice bisDevice)
    {
        bisDevice.setCreateTime(DateUtils.getNowDate());
        return bisDeviceMapper.insertBisDevice(bisDevice);
    }

    /**
     * 修改蔬菜机
     * 
     * @param bisDevice 蔬菜机
     * @return 结果
     */
    @Override
    public int updateBisDevice(BisDevice bisDevice)
    {
        bisDevice.setUpdateTime(DateUtils.getNowDate());
        return bisDeviceMapper.updateBisDevice(bisDevice);
    }


    /**
     * 批量删除蔬菜机
     * 
     * @param deviceIds 需要删除的蔬菜机主键
     * @return 结果
     */
    @Override
    public int deleteBisDeviceByDeviceIds(Long[] deviceIds)
    {
        return bisDeviceMapper.deleteBisDeviceByDeviceIds(deviceIds);
    }

    /**
     * 删除蔬菜机信息
     * 
     * @param deviceId 蔬菜机主键
     * @return 结果
     */
    @Override
    public int deleteBisDeviceByDeviceId(Long deviceId)
    {
        return bisDeviceMapper.deleteBisDeviceByDeviceId(deviceId);
    }

    @Override
    public boolean checkDeviceCode(String deviceCode, Integer deviceId) {
        Integer count=this.bisDeviceMapper.checkDeviceCode(deviceCode,deviceId);
        return count>0?true : false;
    }

    @Override
    public BisDevice getDeviceByDeviceCode(String deviceCode) {
        return this.bisDeviceMapper.getDeviceByDeviceCode(deviceCode);
    }
}
